package com.maimeng.Config;



import com.maimeng.Services.CacheServiceX;
import com.maimeng.Services.RedisCache;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;


@Configuration
public class BeanConfig {

    @Value(value = "${cache.expire}")
    private int timeout;
    @Bean
    public RedisCache redisCache()
    {
        RedisCache redisCache = new RedisCache("127.0.0.1","6379");
        redisCache.setTimeout(this.timeout);
        return redisCache;
    }

    @Bean
    public CacheServiceX cacheServiceX()
    {
      return new CacheServiceX(this.redisCache());
    }


    @Bean
    public DataSource dataSource()
    {
        com.alibaba.druid.pool.DruidDataSource dataSource=new com.alibaba.druid.pool.DruidDataSource();

        dataSource.setUrl("jdbc:mysql://rm-uf6y34nm9525fyf01o.mysql.rds.aliyuncs.com/maimeng?characterEncoding=UTF-8&useSSL=false");
        dataSource.setUsername("root");
        dataSource.setPassword("CfWXVUprWpfA7E7NhzkI");
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        return  dataSource;
    }

}
